package cn.yourkingda.module;

import java.util.List;

import org.nutz.ioc.annotation.InjectName;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Fail;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;

import cn.yourkingda.pojo.Employee;
import cn.yourkingda.service.EmployeeService;
import cn.yourkingda.util.MyJson;

@InjectName("employeeModule")
@Fail("json")
public class EmployeeModule {
	private EmployeeService employeeService;
	/**
	 * 更新数据
	 */
	@At("/mvc/employee/update")
	@Ok("json")
	@Fail("json")
	public MyJson updateEmployee(@Param("id") int id,@Param("..") Employee employee){
		employee.setId(id);
		return employeeService.updateEmployee(employee);
	}
	/**
	 * 显示数据
	 */
	@At("/mvc/employee/list")
	@Ok("json")
	@Fail("json")
	public List listEmployee(){
		return employeeService.listEmployee();
	}
	/**
	 * 删除数据
	 */
	@At("/mvc/employee/del")
	@Ok("json")
	@Fail("json")
	public MyJson delEmployee(@Param("id") int id){
		employeeService.delEmployee(id);
		MyJson myJson = new MyJson();
		myJson.setStatus(1);
		myJson.setMsg("删除成功");
		return myJson;
	}
	
}
